<template>
  <div>
    <el-form ref="myform" :model="formItem" label-width="100px" size="mini" class="form-view">
      <el-row :gutter="40">
        <el-col :span="24">
          <el-form-item label="操作">
            {{ formItem.operationName }}
          </el-form-item>
        </el-col>
      </el-row>
      <el-row :gutter="40">
        <el-col :span="24">
          <el-form-item label="备注">
            {{ formItem.remarks }}
          </el-form-item>
        </el-col>
      </el-row>
    </el-form>
  </div>
</template>

<script>
import { detail } from '@neu/dcom-ui/api/incidentConfirm'
const formItem = {
  operationName: ''
}
export default {
  name: 'IncidentConfirmView',
  components: {

  },
  props: {
    taskId: {
      required: false,
      type: String,
      default: 'NULL'
    },
    workOrderNum: {
      required: false,
      type: String,
      default: ''
    }
  },
  data() {
    return {
      // 编辑的表单内容
      formItem: {
        ...formItem
      },
      // 表单验证规则
      rules: {
        operation: [{
          required: true,
          message: '操作不能为空',
          trigger: 'change'
        }]
      }
    }
  },
  watch: {
  },
  created() {
    this.fetch()
  },
  methods: {
    fetch() {
      if (this.workOrderNum !== 'NULL') {
        detail(this.workOrderNum, this.taskId).then(response => {
          this.formItem = {
            ...response.data
          }
          this.operations = [
            { value: 'serviceDesk', label: '转服务台' },
            { value: 'question', label: '转问题' },
            { value: 'change', label: '转变更' },
            { value: 'reject', label: '驳回' },
            { value: 'confirm', label: '确认' },
            { value: 'close', label: '关闭' }
          ]
          const operationSet = this.operations.filter(t => {
            return t.value === this.formItem.operation
          })
          this.formItem.operationName = operationSet && operationSet.length > 0 ? operationSet[0].label : ''
        })
      } else {
        this.formItem = {
          ...formItem
        }
      }
    }
  }
}
</script>
